﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class basecon_message : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public bool Sent
    {
        set
        {
            this.lbDel.Attributes.Add("Sent", value.ToString());
        }
        get
        {
            if (this.lbDel.Attributes["Sent"] == null)
            {
                return false;
            }
            return Convert.ToBoolean(this.lbDel.Attributes["Sent"]);
        }
    }

    public int UserGuid
    {
        set
        {
            this.lbDel.Attributes.Add("UserGuid", value.ToString());
        }
        get
        {
            return Convert.ToInt32(this.lbDel.Attributes["UserGuid"]);
        }
    }

    public int MesGuid
    {
        set
        {
            this.lbDel.Attributes.Add("MesGuid", value.ToString());
            Message mes = new Message(value);
            this.labDate.Text = mes.CreateTime.ToString();
            if (!this.Sent)
            {
                if (!mes.ReadYeat(this.UserGuid))
                {
                    this.trMessage.Style.Add("font-weight", "bold");
                }
                string s = mes.SenderName(this.UserGuid);
                this.labSender.Text = Fun.CutStr(s, 16);
                this.labSender.ToolTip = s;
            }
            else
            {
                this.labSender.Text = mes.RecversNum.ToString() + "位收件人";// Fun.CutStr(mes.Recvers, 6);
                //this.labSender.ToolTip = mes.Recvers;
            }
            this.hlMessage.Text = Fun.CutStr(mes.Title, 30);
            this.hlMessage.ToolTip = mes.Title;
            //this.hlMessage.NavigateUrl = Params.AdminFolderHttp + "message.aspx?guid=" + mes.Guid.ToString();
            this.lbDel.Attributes.Add("onclick", "return confirm('确定删除？')");
        }
        get
        {
            return Convert.ToInt32(this.lbDel.Attributes["MesGuid"]);
        }
    }
    protected void lbDel_Click(object sender, EventArgs e)
    {
        //Relationship.Update(this.UserGuid,mes
        //string sql = "";
        if (this.Sent)
        {
            Relationship.Update(this.UserGuid, Message.StrSent, this.MesGuid, Message.StrDel);
        }
        else
        {
            Relationship.Update(this.UserGuid, Message.StrRead, this.MesGuid, Message.StrDel);
            Relationship.Update(this.UserGuid, Message.StrRecv, this.MesGuid, Message.StrDel);
        }
        //Session.Add(Params.SystemError, "删除成功");
        Fun.Refresh("删除成功");
    }

    public string FolderHttp
    {
        set
        {
            this.hlMessage.NavigateUrl = value + "message.aspx?guid="+this.MesGuid.ToString()+"&uid="+Request.Params["uid"];
        }
    }
}
